<?php
//表单验证类基类
/**
 * Check类主要职责：该类是真正作为验证数据和报错的类，当然它的验证方法封装在
 * Validate里面了，这样可以提高重用性
 */
class Check extends Validate {
    protected $flag = true;       //验证结果(boolean)默认为true
    protected $message = array();    //错误消息集合
    protected $tpl = null;

    public function __construct() {
        $this->tpl = TPL::getInstance();
    }
    public function oneCheck(Model &$model,Array $condition) {
        if(!$model->isOne($condition)) {
            $this->flag = false;
            $this->message[] = '指定的数据不存在!';
        }
        return $this->flag;
    }
    //错误提示跳转
    public function displayError($url = '') {
        if(empty($url)) {
            $this->tpl->assign('message',$this->message);
            $this->tpl->assign('prev',Tool::getPrevPage());
            $this->tpl->display(SMARTY_ADMIN.'public/error.html');
            exit();
        } else {
            Redirect::getInstance()->succ($url);
        }
    }



}


?>